﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once

#include "GcmpGeometryInterface.h"
#include "IPlaneCurve3d.h"
#include "GbmpConstants.h"

namespace gcmp
{
    class IEllipse2d;

    /// \brief 三维椭圆
    ///
    class IEllipse3d : public IPlaneCurve3d
    {
        DEFINE_CAST_DERIVED(gcmp::IEllipse3d, gcmp::ICurve3d);
    public:
        /// \brief  根据圆心、法向、长轴、长轴半径、短轴半径、起始角度、终止角度，逆时方向构造三维椭圆
        /// \param centerPoint        椭圆圆心
        /// \param normal          椭圆所在平面的法向
        /// \param majorAxis       椭圆长轴(单位化向量)
        /// \param majorRadius       长轴半径
        /// \param minorRadius       短轴半径
        /// \param startAngle       起始角度（弧度,默认0.0）
        /// \param endAngle       终止角度（弧度,默认gcmp::Constants::MATH_2PI）
        /// \param anticlockwise  时针方向（逆时针为true，顺时针为false）
        /// \return  三维椭圆
        /// \see 当输入短轴半径大于长轴半径时，进行互换，保证短轴半径始终小于等于长轴半径
        GCMP_GEOMETRY_INTERFACE_EXPORT static OwnerPtr<IEllipse3d> Create(
            const Vector3d &centerPoint,
            const Vector3d &normal,
            const Vector3d &majorAxis,
            double majorRadius,
            double minorRadius,
            double startAngle = 0.0,
            double endAngle = Constants::MATH_2PI,
            bool anticlockwise = true
        );

        /// \brief     构造三维椭圆弧
        /// \param centerPt     中心点
        /// \param normal       法向
        /// \param majorAxis    长轴单位向量
        /// \param pIEllipse2d    二维椭圆弧
        /// \return  三维椭圆弧
        GCMP_GEOMETRY_INTERFACE_EXPORT static OwnerPtr<IEllipse3d> Create(
            const Vector3d &centerPt,
            const Vector3d &normal,
            const Vector3d &majorAxis,
            const IEllipse2d* pIEllipse2d
        );


    public:
        
        /// \brief  获取椭圆圆心
        /// \return 圆心
        virtual Vector3d GetCenter() const = 0;

        /// \brief  设置椭圆圆心
        /// \param centerPoint  圆心
        /// \return 成功返回true,否则返回false(默认返回True)
        virtual bool SetCenter(const Vector3d& centerPoint) = 0;

        /// \brief  获取椭圆长轴正方向
        /// \return 长轴正方向（单位向量）
        virtual Vector3d GetMajorAxis() const = 0;

        /// \brief  获取椭圆短轴正方向
        /// \return 短轴正方向（单位向量）
        virtual Vector3d GetMinorAxis() const = 0;
        
        /// \brief  获取椭圆长轴半径
        /// \return 长轴半径
        virtual double GetMajorRadius() const = 0;
        
        /// \brief  获取椭圆短轴半径
        /// \return 短轴半径
        virtual double GetMinorRadius() const = 0;

        /// \brief  获取起始角度
        /// \return 起始角度
        virtual double GetStartAngle() const = 0;

        /// \brief  获取终止角度
        /// \return 终止角度
        virtual double GetEndAngle() const = 0;

        /// \brief  获取时针方向，true：逆时， false：顺时
        /// \return 时针方向
        virtual bool IsAntiClockwise() const = 0;
        
    public:
        virtual ~IEllipse3d() {}
    };
}
